Computer implemented data parsing for DSP

ABSTRACT

Execution of a single stand-alone instruction manipulates two n bit strings of data to pack data or align the data. Decoding of the single instruction identifies two registers of n bits each and a shift value, preferably as parameters of the instruction. A first and a second subset of data of less than n bits are selected, by logical shifting, from the two registers, respectively, based solely upon the shift value. Then, the subsets are concatenated, preferably by a logical OR, to obtain an output of n bits. The output may be aligned data or packed data, particularly useful for performing a single operation on multiple sets of the data through parallel processing with a SIMD processor.

FIELD OF THE INVENTION

[0001] The present invention relates to data manipulation, for example to align and pack data elements from a stream of data for subsequent parallel processing.

BACKGROUND OF THE INVENTION

[0002] Data processing, particularly with respect to streaming data and parallel processing has suffered from the limits of existing processor instructions, with respect to low speed relative to the speed of the streaming data, as well as the complexity of the number of instructions and the amount of code required to execute needed functions.

[0003] Computer processors allowing for packed SIMD (Single Instruction Multiple Data) type of operations, i.e. performing one operation on multiple sets of data through the use of parallel processing, are designed, for example, to speed up standard digital filter operations in digital signal processing (DSP). This is achieved by exploiting some of the characteristic symmetry inherent in digital filter equations. These operations find a broad range of applications in most signal processing algorithms like Fast Fourier Transform (FFT), FIR/IIR filters and trigonometry, as well as in statistical analysis algorithms. This class of operations is specifically for data manipulation within a packed register.

[0004] As a specific example, a plurality of small equal length numbers are packed into a 64 bit double word as elements of a vector and then the elements are extracted and parallel operated upon independently. The SIMD operation requires that these data elements be aligned within the double word. However, the data as received is frequently not aligned for the SIMD operation and there have been many attempts to obtain such alignment of the input data in an efficient manner, with respect to such factors as processing time, power, hardware complexity and software complexity.

[0005] There is a need for efficient data alignment and packing.

[0006] U.S. Pat. No. 5,898,601 issued Apr. 27, 1999 to Gray et al, with respect to SIMD processing, compresses bit formats provided in a first packed data sequence with five instructions: generates a second packed data element sequence by copying the first packed data sequence, masks a portion of the first packed data, shifts data elements of the first packed data sequence independently by separate shift counts, masks a portion of the second packed data sequence, and joins the second and first packed data sequences.

[0007] U.S. Pat. No. 5,922,066, issued July 1999 to Seongrai Cho et al, discloses a hardware data aligner of a SIMD processor, wherein the aligner shift operation changes the positions of data elements in a data vector to align a data to a base address that is an even multiple of the number of bytes in a data vector. An example of usage would be the alignment of input data to 32 bit boundaries for four bytes of input data.

[0008] Both U.S. Pat. No. 5,933,650 issued Aug. 3, 1999 to van Hook et al and U.S. Pat. No. 6,266,758B1 issued Jul. 24, 2001 to van Hook et al relate to data alignment and SIMD processing. A first data vector is loaded from a memory into a first register and a second vector is loaded from the memory into a second register. A starting byte in the first register is determined by being specified as a constant in an alignment instruction and the starting byte specifies the first byte of an aligned vector. A subset of elements is selected from the first register and the second register; a first width vector from the first register and the second register is extracted beginning from the first bit in the first byte of the first register continuing through the bits in the second register. The elements from the subset are then replicated into elements in a third register in a particular order suitable for subsequent SIMD processing. FIG. 5 shows an example of extracting an aligned vector from two vectors.

[0009] U.S. Pat. No. 6,094,637 issued Jul. 25, 2000 to Hong reverses the order of data elements in a vector register for SIMD processing.

[0010] U.S. Pat. No. 6,175,892 issued Jan. 16, 2001 to Sazzad et al specifies a row and/or column of data with a SIMD instruction operand, particularly for a two-dimensional register array.

[0011] U.S. Pat. No. 6,460,127 B1 issued Oct. 1, 2002 processes a plurality of samples of an incoming signal in parallel, by including operations such as those in the listing spanning columns 26 and 27.

[0012] U.S. Pat. No. 6,243,803 discloses a method and apparatus for computing packed absolute differences with a plurality of sign bits using SIMD add circuitry.

[0013] Example shift instructions for SIMD processing include: PSLLW, PSLLD, PSLLQ-Shift Packed Data Left Logical; PSRLW, PSRLD, PSRLQ-Shift Packed Data Right Logical; and PSRAW, PSRAD-Shift Packed Data Right Arithmetic. These instructions shift the destination elements the number of bits specified in the count operand.

[0014] Therefore, there is a need for an improved instruction to improve data manipulation, particularly for subsequent parallel processing at a higher speed relative to existing instructions and of less complexity to execute needed functions, particularly including aligning and packing data elements from a stream of data.

SUMMARY OF THE INVENTION

[0015] These and other needs are addressed by the present invention.

[0016] As a result of analyzing the prior art, the inventor has found a need for an improved instruction for data manipulation, particularly for subsequent parallel processing at a higher speed and of less complexity to execute needed functions that particularly include aligning and packing data elements from a stream of data.

[0017] Therefore, the present invention analysis of the prior art system as to its problems and their causes has lead to the need for and the solution of a more effective data manipulation instruction, as well as a system and method using the instruction.

[0018] Operations for digital filters and packed data manipulation are specifically for data manipulation within a packed register. In many applications for signal processing as well as in data parsing, the data is continuous, packed and of various data types and precisions. The operations of the present invention allow for direct extraction as well as creation of such data, which will allow for packed arithmetic to be applied to this problem.

[0019] Most fixed point DSP applications and algorithms fall into the domain of the instructions of the present invention. Current applications based on streaming audio and streaming video, require the handling of compressed data in fixed point packed format consisting of data types of different sizes and alignments, and may also consist of bit fields. Streaming data has no consideration of alignment and is unsuitable for SIMD processing directly. Continuous extraction as well as continuous creation of such data streams is desirable and has been a big overhead for most DSP applications in the form of many instructions required for data manipulation associated with multiple shifts, logical operations (like masking, AND and OR), and a large number of load store operations. There has also been data alignment overhead associated with load store operations.

[0020] The present invention identifies and addresses three problems of streaming data that the prior art handles in C code: there is a variable bit length of different adjacent data elements; there is no consideration of alignment; and the data is continuous, e.g. among packets.

[0021] The present invention identifies these problems and their causes and addresses the solution to these problems with a stand alone single data manipulation instruction requiring at most three parameters to specify registers and a shift value used to control shift and logical operations for data alignment or data packing, particularly for streaming data. As a result, when compared to the prior art, the present invention reduces the number of memory operations, and reduces the number of logical instructions.

[0022] Still other aspects, features, and advantages of the present invention are readily apparent from the following detailed description, by illustrating a number of particular embodiments and implementations, including the best mode contemplated by the inventor for carrying out the present invention. The present invention is also capable of other and different embodiments, and its several details can be modified in various obvious respects, all without departing from the spirit and scope of the present invention. Accordingly, the drawing and description are to be regarded as illustrative in nature, and not as restrictive.

BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawing, in which like reference numerals refer to similar elements, and in which:

[0024]FIG. 1 illustrates the PSHIFT instruction or operation of the present invention, for an exemplary shift_val=33;

[0025]FIG. 2 shows a computer system of the present invention for executing PSHIFT and SHIFTPACK operations according to the present invention;

[0026]FIG. 3 shows the execution unit of FIG. 2 in representative greater detail;

[0027]FIG. 4 is an architecture block diagram for the execution of the PSHIFT instruction of the present invention, for an exemplary shift_val=33;

[0028]FIG. 5 shows a representative scenario for data packing employable with the SHIFTPACK instruction of the present invention;

[0029]FIG. 6 illustrates the SHIFTPACK instruction or operation of the present invention, for an exemplary shift_val=33;

[0030]FIG. 7 is an architecture block diagram for the execution of the SHIFTPACK instruction of the present invention;

[0031]FIG. 8 is another embodiment architecture block diagram for execution of the SHIFTPACK instruction; and

[0032]FIG. 9 is a flowchart of a system and program using the PSHIFT operation and the SHIFTPACK operation.

DESCRIPTION OF THE PREFERRED EMBODIMENT

[0033] The computer architecture shown in FIG. 2 includes existing hardware for packed arithmetic occurring in a standard SIMD processing unit 200. SIMD processing unit 200 is enhanced by combination with a computer readable storage 207 having data as computer readable code that includes three specific instructions, namely PSHIFT, SHIFTPACK AND SEXTN, which are decodable with the instruction decode unit 202 and executable with the execution unit 203, according to the present invention. The execution unit 203 is coupled to the integer register file 204 and the load store unit 205, in a known manner. Additional control signals may be required depending on the implementation of the SIMD micro architecture processing unit 200.

[0034] The exemplary hardware circuits used include an audio interface including a sound card and speakers combination 207 for audio processing; a memory 208, including RAM, ROM, FLASH, and hard drive memories, for example, which may be peripheral, on a board or on chip with the processor of the execution unit; a user interface 209 of any known type, including a mouse, a keyboard, a touchpad, WAN connection and voice recognition for communication with a user or agent; a video interface including a capture card and LCD combination 210 for visual arts processing; the SIMD processing unit (including parallel operating central processing units) 200; and one or more buses 211 to operatively couple these components.

[0035] The standard SIMD processing unit 200 includes an internal bus that couples the integer register file 204 (e.g. an intermediate double precision register), the execution unit 203 (shown in greater detail in FIG. 3) that has arithmetic logical and control units as required to execute each instruction, the load store unit 205, an I/D Cache 206, and an instruction decode unit 202 capable of decoding the instruction opcodes native to the processor as well as the new instruction opcodes PSHIFT, SHIFTPACK and SEXTN. The integer register file 204, as another example, may be a single width size register, called RegSize herein; this size can be different for different processors.

[0036] An exemplary execution unit 203 for execution of the pipe shifter instruction PSHIFT in a shift operation in a processor is shown in further detail in FIG. 3 to include: a logical unit 301 having circuits that include hardware logic for Boolean logic operations like OR and AND; The ALU (Arithmetic Logic Unit) 302 that has circuits and hardware for adders, multipliers and accumulators; a multiplier 303; a shifter unit 304; and control unit 305. The control unit 305 has hardware, for example, control lines, multiplexers (MUX) and latches. As a part of the SIMD processing unit 200, the control unit 305 will also include symmetric shifters, multipliers, logical circuits and control circuits or combinations of these depending on the SIMD operations to be performed. This instruction or operation may be implemented in a standard processor using the standard circuits for the shifter unit 304 and the logical unit 305 having the logical ‘OR’ operation.

[0037] The pipe shifter instruction, PSHIFT, manipulates packed data to align it by effectively logically shifting two concatenated register contents by a given shift value to obtain a result that represents the lower ‘single width’ value of the concatenated register with the given shift applied to it. The pipe shifter instruction, PSHIFT, is also an operation for bit extraction. Logically shifting is performed in many ways, some of which are shown in detail herein and include logical shifters, arithmetic shifters followed by null loading, generating a logical mask and performing a Boolean AND with shifted data and right shifting followed by left shifting.

[0038] Exemplary code for the use of the instruction PSHIFT, as shown in FIG. 1, uses: PSHIFT reg_1,reg_2, shift_val, which is executed as follows: LINE 1: tmp_=reg_1 <<(RegSize-shift by shift_val) OR (reg_2>> shift by shift_val); and LINE 2: reg_2=tmp_reg.

[0039] The values or parameters used in the example execution of PSHIFT as shown in FIG. 1 are reg_1=register 402, reg_2=register 403, and shift_val=33. The logic block diagram of FIG. 1 shows an exemplary implementation for input registers 402 and 403 of bit size n. The number of bits required to specify the unsigned Shift_val is, Log₂ n. LINE 1 is executed by the shifter unit 304, the logical unit 301 and the control unit 305.

[0040] The Pipe Shifter instruction, PSHIFT, is useful in applications for: parsing algorithms, for example, Huffman and variable length coding (VLC); most fixed point arithmetic; unpacking of data, for example, bit fields; normalization and fixed-point arithmetic for example for digital filters; and replacing aligned data extract instructions in SIMD or general purpose processors, for example, the general purpose processor SH-5 of Hitachi Ltd. that employs the instruction MEXTRx, which extracts a combination of bytes from two registers. Also, the PSHIFT instruction is useful in applications using fixed point and packed data types, which includes most fixed point DSP (Digital Signal Processor) applications and algorithms.

[0041] Current applications based on streaming audio and streaming video, require the handling of compressed data in fixed point packed format consisting of data types of different sizes and alignments and which compressed data may also consist of bit fields. This involves continuous extraction of such data streams as well as creation of such data streams. This has been a big overhead for most DSP applications in the form of data manipulation associated with multiple shifts and logical operations like masking and OR, and a large number of required load store operations. There has also been data alignment overhead associated with load store operations.

[0042] As shown in FIG. 4, an exemplary computer architecture having 64-bit register sizes implements the PSHIFT instruction. FIG. 4, as suggested by the pseudo code, is a stand-alone implementation, meaning that it does not require the support of other instructions to align data. The L (left) barrel shifter 404 and R (right) barrel shifter 405 may be discrete circuits or dual barrel shifters as may be found commonly in SIMD or vector processors. The registers 402 and 403 of the execution unit of FIG. 3 feed their content, of n bits, to the barrel shifters 404, 405, respectively. The two shift coefficients required for the L barrel shifter 404 and the R barrel shifter 405 are supplied as n-Shift_val and Shift_val, respectively. The shifting provided by the L barrel shifter 404 and the R barrel shifter 405 is preferably logical, that is with the loading of nulls. The Shift_val term is the instruction parameter obtained as input 401 from the instruction decode unit 202 of FIG. 2 by decoding the instruction PSHIFT, and the n-Shift_val term is easily computed from the Shift_val term using the two's complement circuit 406.

[0043] The OR gate 407 performs the logical OR operation to combine the outputs of the two shift operations performed in the L barrel and R barrel shifters, 404, 405. The result of the logical OR operation is held in the OUTPUT 408, which may be the output node of the OR gate, as in FIG. 1, or the OUTPUT 408 may be held in the temporary register 120 of FIG. 1, or the OUTPUT 408 may be held in the register 403. The actual implementation used in a commercial embodiment depends on the available hardware.

[0044] The data manipulation provided by the pipe shift operation of the single stand alone instruction PSHIFT is generic and replaces a plurality of standard SlMD instructions for byte level data unpacking (for example PSHIFT replaces the MEXTRX operation in the SuperH SH-5 processor of Hitachi Ltd. Also, SIMD or vector architectures perform asymmetric shifting by using the two shift operations involved in the execution of PSHIFT.

[0045]FIG. 9 is a flowchart of the processing performed with respect to the execution of a program that includes one or more of the instructions PSHIFT and SHITFTPACK, as performed on the exemplary SIMD computer system of FIG. 2. The program is implemented in computer readable data stored in tangible form on the memory 208.

[0046] STEP 900 includes various steps that may be conventional or not, in preparation for execution of a program or execution of a program segment, for example, including various start up procedures.

[0047] STEP 905 fetches from memory 208 the next instruction to be executed by the execution unit 203 according to the flow of the program and by using various known procedures. The fetched next instruction is then decoded in the instruction decode unit 202. The execution unit is shown in more detail in FIG. 3.

[0048] STEP 910 determines if the thus fetched and decoded instruction is a PSHIFT instruction. If it is not a PSHIFT instruction, processing continues with step 915 and when it is a PSHIFT instruction, processing continues with step 930.

[0049] STEP 915 determines if the thus fetched and decoded instruction is a SHIFTPACK instruction. If it is not a SHIFTPACK instruction, processing continues with step 920 and when it is a SHIFTPACK instruction, processing continues with step 965.

[0050] STEP 920 executes the current instruction, which is neither a PSHIFT nor a SHIFTPACK instruction, and processing continues with step 925.

[0051] STEP 925 determines if the program has ended, and if it has, the operation of FIG. 9 stops, even though the computer may continue to operate or stand-by in a known manner. When it is determined that the program has not ended, processing continues with step 905, as explained above.

[0052] STEP 930 is reached when step 910 determines that the current instruction is a PSHIFT instruction. As mentioned, the PSHIFT instruction includes the parameter shift_val, the value of which was obtained during decoding in step 905 and is the input 401 of FIG. 4. Further the instruction PSHIFT, as decoded, directly or indirectly or inherently identifies the first and second registers 402 and 403. Preferably, such register identification is with the parameters reg_1 and reg_2 of the PSHIFT instruction.

[0053] The actual bit encoding of the instruction PSHIFT depends upon the hardware architecture. PSHIFT is either dynamic or logical, meaning that the parameter shift_val is either specified in a register or as an immediate constant value. The identity of registers 402, 403, 404, 405 and 120 may be fixed or named once and their identities maintained for executing of subsequent PSHIFT instructions, but preferably, the registers 402, 403 are identified by the parameters of the instruction PSHIFT.

[0054] STEP 940 loads the next double wide streaming data from the memory 208, the audio interface 207, the video interface 210 or the user interface209 of FIG. 2, any of which may provide data from a LAN or WAN (including the internet), for example, into the registers indicated by the decoding of the PSHIFT instruction. For example, the next two words of the streaming data (n bits for each word) are loaded into registers 402 and 403. Then the procedure passes to step 945.

[0055] STEP 945 transfers the n bit contents of each of the registers 402 and 403 respectively to the barrel shifters 404 and 405, as indicated in FIG. 4. Thereafter, the procedure passes to step 950.

[0056] STEP 950 performs data shifts. In the example the data in the L barrel shifter 404 is logically shifted left a number of bits equal to the register size n minus the shift value (the value of shift_val), which in the exemplary case of the registers being of a size n=64 and the shift value being 33, 31 zeroes (64-33) are moved into the right of the barrel shifter 404 and the previous data 0:32 is now aligned to the left and nulls are now in positions 30:0, as seen in FIG. 1. In the example, the data in the R barrel shifter 405 is logically shifted right a number of bits equal to the shift value, which in the exemplary case with the shift value being 33, 33 zeroes or nulls are moved into the left of the barrel shifter 405 and the previous data 63:33 is now aligned to the right with nulls in positions 63:31, as seen in FIG. 1. Being logical shifting, nulls or zeros are loaded, and in the exemplary implementation, nulls are loaded into the L barrel shifter 404 from the right on the data transferred from the register 402 and nulls or zeros are loaded into the R barrel shifter 405 from the left on the data transferred from the register 403, as shown in FIGS. 1 and 4.

[0057] As used herein, shifting is broadly described as in FIGS. 1 and 9, wherein the beginning data is compared to the output data and it is seen that subdivisions in the two inputs of data have been moved a number of bit positions equal to the number of nulls loaded. Loaded, as used herein, refers to the entry of data, here nulls, into a memory (for example, a temporary memory 102, a register 402, 403, a more permanent memory 408, a shift register 404, 405, or merely briefly appearing at an output node while being transmitted to a remote location), and the term loaded as used herein does not place limitations on where the nulls came from or how they are placed adjacent the subdivision of data. The barrel shifters of the FIG. 4 embodiment perform a linear shift where a bit is inserted at one end and a bit is lost at the other end for each cycle, and the shift is logical in that the bit inserted for each cycle is a null or zero.

[0058] As mentioned above, the shifting may be arithmetic, which is not the best mode although contemplated according to the broader aspects of the invention. In the present invention, the new combination of the PSHIFT pipe shifter instruction with arithmetic shifting and a sign extension instruction, for example SEXTN (an existing sign extension instruction to sign or zero extend from a given bit position), is also useable to extract data, for example with cyclic or looped shift registers. The SEXTN instruction may exist by itself in some processors and implementations in the prior art. The syntax is: SEXTN var,bit_pos.

[0059] Logical shifting is usually available in a processor and would involve less processing than arithmetic shifting.

[0060] The logical shifting is performed in the barrel shifters 404 and 405 on the data that was transferred from the registers 402 and 403, respectively, and thereafter, the logically shifted data is transferred to the registers 402 and 403, respectively.

[0061] All of the shifting performed by step 950 is under the control of the value of shift_val. In the example, the value of shift_val is 33 and this value is sent to the L barrel shifter 404 in binary form with a bit length of Log₂ n and is sent to the R barrel shifter 405 in binary form as the two's complement of 33 with a bit length of Log₂ n. The two's complement is obtained with the 2's complement circuit or software 406 of FIG. 4, which is commonly found in processors, particularly SIMD processors.

[0062] For example: after step, 940 register 402 has n bit values 111011001000100011110001010111010010110111010101011101010100101; after step 950 with a shift value of 33, shifter 404 has bit values 0100101101110101010111010101001010000000000000000000000000000000; after step 940, register 403 has n bit values 111001111000111110000111111000001111111000000111111110000000111; and after step 950 right shifting with a shift value of 33, shifter 405 has bit values 0000000000000000000000000000000001110011110001111100001111110000.

[0063] STEP 955 performs a logical OR with the logical unit 301 of FIG. 3 of the execution unit 203, particularly the OR gate 407 of FIG. 4. The result of the logical OR is stored in temporary register 120 of FIG. 1, and then the result is transferred to another register, for example, register 403 in FIG. 1, although other registers are contemplated, for example a third register, not illustrated. After step 955, the register chosen to hold the aligned data, for example register 403 of FIG. 1, has the representative, now aligned, data with the data elements in alignment suitable for SIMD processing, as follows 0100101101110101010111010101001011110011110001111100001111110000.

[0064] STEP 960 processes the aligned data elements, which for vector processing may be the next two one byte wide elements. With the present invention, shift_val may have any value desired and the data elements processed may have any value and be variable length within the subdivisions of data. Also it is contemplated that the now aligned data elements may be stored for later processing or transmitted to another location for storage or processing.

[0065] The aligned individual data elements in output register 403 may be extracted by masking and shifting repeatedly according to known procedures. After SIMD processing the procedure moves through steps 905 and 910 to step 930 when the next instruction is a PSHIFT instruction.

[0066] Since the value for shift_val may be any number within the range of the register size n, the invention is not limited to fixed size data elements. The PSHIFT instruction may be used for bit alignment and extraction. Thus the PSHIFT instruction may be used for the alignment and extraction of data elements of any length, including bit extraction.

[0067] The present invention approach allows for a number of data extractions for data of arbitrary sizes from consecutive memory loads with just two instructions per data type. The pipe shifter instruction PSHIFT is useable to extract data of arbitrary size from a combination of two registers, which typically may represent consecutive memory locations. Since data types are extracted ‘in-register’, data is loaded continuously from memory using the maximum allowable machine word size without regard for the data type or the alignment contained in the data, thus maximizing memory throughput.

[0068] A data pack function is provided by the data manipulation instruction SHIFTPACK. SHIFTPACK is complementary to the data unpack or alignment function provided by the data manipulation instruction PSHIFT.

[0069] SHIFTPACK is used for fixed point and packed data types, e.g.: parsing algorithms like Huffman or variable length coding (VLC) or bit packing, as well as for non-standard fixed-point data handling in DSP operations; most fixed point arithmetic DSP algorithms; and packing data structures or bit fields.

[0070] The SHIFTPACK instruction packs data of arbitrary size into a packed data word. The instruction may be used in the execution of scenarios such as depicted by FIG. 5. FIG. 5 shows the general mechanism used to pack independent data units 501of different sizes with MUX (multiplexer) logic 502 into an output of continuous packed data. Typically, the input 501 may be encoded data or variable length codes (VLCs). The packing outputs one maximum word data size (machine word size) at a time. For example, a decision process 503 checks the data size against the word size and starts another word with process 505 when the next data element inclusion would exceed the capacity of the current word. The output buffer 504 therefore holds a continuous packed data stream.

[0071] Exemplary code for the use of the instruction PSHIFTPACK, as shown in FIG. 6, uses: SHIFTPACK reg_1,reg_2, shift_val, which is executed as follows with respect to an example of usage: LINE 1: SHIFTPACK reg_1,reg_2, shift_val; LINE 2: Tmp_reg=reg_1 left shift by shift_val; LINE 3: reg_1=Tmp_reg OR (shift_mask AND reg_2), where shift_mask=shift_val number of set bits.

[0072] The values or parameters used in the example execution of SHIFTPACK as shown in FIG. 6 are reg_1=register 402, reg_2=register 403, and shift_val=33. The logic block diagram of FIG. 6 shows an exemplary implementation for input registers 402 and 403 of bit size n. The number of bits required to specify the unsigned Shift_val is, Log₂ n.

[0073] A mask is a pattern of bits used to accept or reject bit patterns in another set of data. For example, if shift_val=4; shift_mask=000 . . . 0001111=2^(shiftd) ^(_(—)) ^(val)− 1. In the example of FIG. 6, the mask provided has thirty-one zeroes followed by thirty-three ones, under the control of the shift_val=33. LINE 2 is performed in the shifter unit 304 of FIG. 3 and LINE 3 is performed with the logical unit 301 and the control unit 305 of FIG. 3.

[0074]FIG. 7 is an architecture block diagram for the execution of the SHIFTPACK instruction. The registers 402 and 403 receive adjacent streaming data. The L barrel shifter 404 shifts the data from register 402 in the same manner as the L barrel shifter 404 of FIG. 4, and the L barrel shifter 404 is under control of the shift_val from input 401. The logic block outputs a series of ones adjacent a series of zeroes for a total of n bits, with the division between the zeros and ones being under the control of the shift_val of input 401, as explained above.

[0075] The Boolean AND operation provided by the AND gate 705 is used to match the mask of zeros and ones from the logic block 706 with a string of data bits from register 403. When one occurs in the mask, the corresponding bit of data is passed from the register 403 to the OR gate 407 unchanged and when zeros are in the mask, the corresponding bits of data from the register are passed only as zeroes to the OR gate 407. The OR gate 407 performs the logical OR operation to combine the outputs of the two logical operations performed in the L barrel shifters, 404 and the AND gate 705. The result of the logical OR operation is held in the OUTPUT 408, which may be the output node of the OR gate, as in FIG. 1, or the OUTPUT 408 may be held in the temporary register 120 of FIG. 6, or the OUTPUT 408 may be held in the register 403 or the register 402 as in FIG. 6, or the output 408 may merely be a node with the data transmitted to a remote location. The actual implementation used in a commercial embodiment depends upon the available hardware.

[0076] The SHIFTPACK instruction replaces existing aligned SIMD or Vector byte level data packing instructions like in the above-mentioned SuperH processor and in SIMD or general-purpose processors. For example in the SH-5 computer, SHORI (shift and OR) MEXTRX extracts a combination of bytes from two registers with constant data.

[0077] The SHIFTPACK instruction is usable to generate addresses in address or pointer based arithmetic, in logical operations and in construction of variable length codes. The three cases of execution disclosed in pseudo-code with respect to FIGS. 6, 7 and 8, are exemplary implementations for SHIFTPACK.

[0078] The SHIFTPACK instruction or operation is implemented in FIG. 6, for example, with a computer system having a standard processor using the standard circuits for the shifter and the logical OR operation, a 64-bit register size and a resident instruction such as a zero extend from bit location instruction, which is the same as the sign extend from bit location instruction mentioned in the description of PSHIFT. The use of such an instruction ensures that no AND masking is required for the second register operand before the OR operation. However this may also be done with the execution of two operations.

[0079] In FIG. 6, an example parameter value for shift_val is 33. The contents of the first register 402 specified by the SHIFTPACK instruction are logically shifted left under the control of shift_val, so that bits 0:30 originally in register 402 are now aligned to the left in the register 402 and bits 0:32 of register 402 are now nulls or zero. The contents of the second register 403 specified by the SHIFTPACK instruction are logically shifted right under the control of shift_val so that bits 0:32 originally in register 403 are now aligned to the right in the register 403 and bits 33:63 of register 403 are now nulls or zero. The OR gate 607 then logically combines the contents of shift registers 404 and 405 to pack the 0:30 bits originally from register 402 and the 0:32 bits originally from register 403 as bits 0:63 of a temporary register 120, whose contents are then output to register 402.

[0080]FIG. 7, as suggested by the pseudo code, is a stand-alone implementation, meaning that it does not require the support of other instructions to pack data. The logic block diagram of FIG. 7 shows input registers 402, 403 of bit size n. The number of bits required to specify the unsigned Shift_val of the input 401 is Log₂ n. The contents of register 402 are transferred to L barrel shifter 404, where they are shifter logically left under the control of the shift value from input 401. The mask 2^(shift) ^(_(—)) _(val)31 1 may be generated by a number of techniques depending on the circuits available. In the exemplary implementation, the contents of register 403 are transferred to the AND gate 705, where a logical AND is performed with the output of logic block 706. The logic block 706, shown in FIG. 7, represents exemplary hardware logic used to generate the mask value. The output of the logic block 706 is used in an AND operation of the AND gate 705 to mask the data in register 403.

[0081] The n bit wide output of the L barrel shifter 404 and the n bit wide output of the AND gate 705 are logically combined, particularly they are subjected to a logical OR by the OR gate 407. The n bit wide result of the logical combination (provided by the logical shifting, the logic block, the AND gate 705 and the OR gate 407) is transferred as an output408, and for example, stored in a register, such as the temporary register 120 or the register 402 as in FIG. 6, or register 403 or elsewhere all as controlled by the decoding of the instruction SHIFTPACK.

[0082] Another exemplary implementation of SHIFTPACK is shown in FIG. 8. FIG. 8, as suggested by the pseudo code, is a stand-alone implementation, meaning that it does not require the support of other instructions to pack data. The logic block diagram of FIG. 8 shows input registers 402 and 403 of bit size n. The number of bits required to specify the unsigned Shift_val of the input 401 is Log₂ n.

[0083] In FIG. 8, the contents of register 402 are transferred to the L barrel shifter 404-1, where they are shifter logically left under the control of the shift value of Shift_val from input 401. The contents of register 403 are transferred to L barrel shifter 404-2, where they are shifter logically left under the control of the shift value from input 401; the control is through the conversion of the input 401 by the 2's complement circuit 406. The output of the L barrel shifter 404-2 is transferred to the R barrel shifter 405, where the bits are shifter logically right under the control of the shift value from input 401; the control is through the conversion of the input 401 by the 2's complement circuit 406.

[0084] The n bit wide output of the L barrel shifter 404-1 and the n bit wide output of the R barrel shifter 405 are logically combined, particularly they are subjected to a logical OR by the OR gate 407. The n bit wide result of the logical OR combination is transferred as an output 408, and for example, stored in a register, such as the temporary register 120 or the register 402 as in FIG. 6, or register 403 or elsewhere all as controlled by the decoding of the instruction SHIFTPACK.

[0085] Therefore, it is seen that FIG. 8, performs a left logical shifting followed by a logical right shifting resulting in a desired masking effect of the data in register 403. Such shifting techniques are commonly used in zero extension operations. The two shift coefficients required are supplied as Shift_val and n-Shift_val. The latter term n-Shift_val is easily computed using the two's complement circuit 406, which is usually a standard circuit in processors such as a SIMD processor or vector processors.

[0086] The register 402, the register 403 and the input 401 of the Shift_val are preferably specified in the decoding of the instruction SIFTPACK according to the best mode of implementing the invention. The barrel shifters 404, 404-1, 404-2, 405 may be discrete circuits or dual barrel shifters as found in SIMD or vector processors. The 2/s complement circuit 406 has been explained above with respect to FIG. 4.

[0087] The implementations of FIGS. 7 and 8 are usable in the scenario of FIG. 5 and implement the exemplary data case of FIG. 6, according to the method of FIG. 9. The actual implementation may vary from FIGS. 7 and 8, depending upon the available hardware.

[0088] In FIG. 9, when a SHIFTPACK instruction is encountered in step 915, step 965 follows.

[0089] STEP 965 is reached when step 910 determines that the current instruction is not a PSHIFT instruction and step 915 determines that the current instruction is a SHIFTPACK instruction. As mentioned, the SHIFTPACK instruction includes the parameter shift_val, the value of which was obtained during decoding in step 905 and is the input 401 of FIGS. 7 and 8. Further the instruction SHIFTPACK, as decoded in step 905, directly or indirectly or inherently identifies the first and second registers 402 and 403. Preferably, such identification is with one or both of the parameters reg_1 and reg_2 of the SHIFTPACK instruction.

[0090] The actual bit encoding of the instruction SHIFTPACK depends upon the hardware architecture. SHIFTPACK is either dynamic or logical, meaning that the parameter shift_val is either specified in a register or as an immediate constant value. The identity of registers 402, 403, 404, 404-1, 404-2, 405 and 120 may be fixed or named once and their identities maintained for executing of subsequent SHIFTPACK instructions.

[0091] STEP 970 loads the next double wide streaming data from the memory 208, the audio interface 207, the video interface 210 or the user interface209 of FIG. 2, any of which may provide data from a LAN or WAN (including the internet), for example, into the registers indicated by the decoding of the SHIFTPACK instruction. For example, the next two words of the streaming data (n bits for each word) are loaded into registers 402 and 403. Then the procedure passes to step 975.

[0092] STEP 975 transfers the n bit contents of the registers 402 to the L barrel shifter 404 for FIG. 7 and 404-1 for FIG. 8. STEP 975 also transfers the n bit contents of the register 403 to the AND gate 705 for FIG. 7 or the L barrel shifter 404-2 and R barrel shifter 405 logical shifting combination as indicated in FIG. 8. Thereafter, the procedure passes to step 980.

[0093] STEP 980 performs logical data shifts. In the example implementations of FIGS. 7 and 8, the data in the L barrel shifter 404 and 404-1 is logically shifted left a number of bits equal to the shift value (the value of shift_val), which in the exemplary case of FIG. 6 with the registers being of a size n=64 and the shift value being 33, 33 zeroes are moved into the right of the barrel shifters 404 and 404-1 and the previous data 0:30 is now aligned to the left and followed by nulls in positions 63:31, as seen in FIG. 6. In the example implementation of FIG. 7, the data from the register 403 is logically shifted right a number of bits equal to the 2's complement of the shift value, which in the exemplary case of FIG. 6 with the shift value being 33, 31 zeroes or nulls are then to the left in the output of the AND gate 705 and the previous data 0:32 is now aligned to the right with nulls in positions 63:33, as seen in FIG. 6. In the example implementation of FIG. 8, the data from the register 403 is first logically shifted left a number of bits equal to the 2's complement of the shift value and then logically shifted right a number of bits equal to the 2's complement of the shift value, which in the exemplary case of FIG. 6 with the shift value being 33, 31 zeroes or nulls are then to the left in the output of the shifter 405 and the previous data 0:32 is now aligned to the right with nulls in positions 63:33, as seen in FIG. 6. Being logical shifting, nulls or zeros are forced or loaded in the data output to the OR gate 407.

[0094] As mentioned above, the logical shifting may initially be arithmetic and then followed by a separate loading of nulls, which is not the best mode although it is contemplated according to the broader aspects of the invention. The logical shifting is performed in the barrel shifters or the combination of the logic block and the AND gate for masking in the embodiments.

[0095] All of the logical shifting performed by step 980 is under the control of the value of shift_val. In the example, the value of shift_val is 33 and this value is used directly and as the two's complement of 33, each in binary form with a bit length of Log₂ n. The two's complement is obtained with the 2's complement circuit or software 406 of FIG. 8, which is commonly found in processors, particularly SIMD processors.

[0096] For example: after step, 975 register 402 has n bit values of 111011001000100011110001010111010010110111010101011101010100101; after step 980 with a shift value of 33, the left input to the OR gate 407 has bit values 0010110111010101011101010100101000000000000000000000000000000000; after step 975, the register 403 has n bit values of 111001111000111110000111111000001111111000000111111110000000111; and after step 980 with a shift value of 33, the right input of OR gate 407 has bit values of 0000000000000000000000000000000001111111000000111111110000000111.

[0097] STEP 985 performs a logical OR with the logical unit 301 of FIG. 3 of the execution unit 203, particularly the OR gate 407 of FIG. 7 or 8. The result of the logical OR is stored in temporary register 120 of FIG. 6, and then the result is transferred to another register, for example, register 402 in FIG. 6 or register 403, although other registers are contemplated, for example a third register, not illustrated. After step 985, the register chosen to hold the packed data, for example register 403 of FIG. 6, has the representative packed data as follows: 0010110111010101011101010100101001111111000000111111110000000111.

[0098] The SHIFTPACK operation is generic and can replace standard SIMD or vector instructions for byte level data packing or extraction, for example the SuperH SH-5 processor has instructions like MEXTRx-Extract to extract a continuous combination of bytes from two registers, or SHORI-shift with constant data. SIMD or vector architectures may also facilitate functionality for asymmetric shifting as is suggested by the multiple shift operations involved in the execution of SHIFTPACK.

[0099] The actual bit encoding of the SHIFTPACK instruction depends upon the hardware architecture. SHIFTPACK may be either dynamic or logical, meaning that the parameter shift_val could be specified in either a register or as an immediate constant value.

[0100] Generically, the instructions SHIFTPACK and PSHIFT are each referred to herein as a data shift instruction, together having the common features and characteristics mentioned above.

[0101] According to the preferred embodiment a barrel shifter is an exemplary shifter, and most barrel shifters have an arithmetic mode and a logical mode. While the arithmetic mode may be used according to the broader aspects of the invention, the preferred mode is the logical mode, which loads nulls or zeros that are useful in the OR operation without additional process steps.

[0102] Conclusion

[0103] The preferred embodiment satisfies the above-mentioned needs by solving the mentioned problems for data manipulation.

[0104] While the present invention has been described in connection with a number of embodiments and implementations, the present invention is not so limited but covers various obvious modifications and equivalent arrangements, which fall within the purview of the appended claims. 

What is claimed is:
 1. A method of manipulating two n bit strings of data, said method being performed by a computer system executing a stand alone implementation of a single instruction that does not require the support of other instructions, comprising the steps of: decoding the single instruction; identifying two registers of n bits each; identifying a shift value; holding the two n bits of data to be manipulated in the two registers, respectively; selecting a first subset of data of less than n bits from one of the two registers based solely upon the shift value; selecting a second subset of data of less than n bits from the other of the two registers based solely upon the shift value; and thereafter concatenating the first subset of data and the second subset of data to obtain an output of manipulated n bits of data.
 2. The method of claim 1, wherein said identifying a shift value identifies the shift value from a parameter of the instruction.
 3. The method of claim 1, wherein the first-mentioned of said steps of selecting comprises logically shifting the bits of data held in the one of the two registers by moving the corresponding subset of data toward one end of the n bits a number of bit positions and adding an equal number of nulls at the other end of the n bits to obtain a first n bits of shifted data; and the second-mentioned of said steps of selecting comprises logically shifting the bits of data held in the other of the two registers by moving the corresponding subset of data toward an end of the n bits a number of bit positions and adding an equal number of nulls at the opposite end of the n bits to obtain a second n bits of shifted data.
 4. The method of claim 3, wherein said step of concatenating performs a logical OR on the outputs of said steps of selecting.
 5. A computer system having SIMD processing architecture, comprising: a processor; a first register; a second register; and a machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 1. 6. A computer system having SIMD processing architecture, comprising: a processor; a first register; a second register; and a machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 2. 7. A computer system having SIMD processing architecture, comprising: a processor; a first register; a second register; and a machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 3. 8. A computer system having SIMD processing architecture, comprising: a processor; a first register; a second register; and a machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 4. 9. A machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 1. 10. A machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 2. 11. A machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 3. 12. A machine readable medium having stored thereon data representing a single instruction executable by said processor to perform the method of claim
 4. 13. The method of claim 3, wherein said steps of identifying are parts of said step of decoding with the shift value and register identities being parameters of the single instruction.
 14. The method of claim 1, wherein said step of logically shifting transfers the contents of the two registers into a left barrel shifter and a right barrel shifter, respectively.
 15. The method of claim 14, wherein said step of identifying a shift value identifies the shift value from a parameter of the instruction; and said step of logically shifting includes supplying a shift coefficient to each of the left barrel shifter and the right barrel shifter as the shift value and n-the shift value, respectively.
 16. The method of claim 15, wherein said supplying includes computing the n-shift value from the shift value by using a two's complement of the shift value.
 17. The method of claim 1, wherein said combining provides aligned combined data; and further including performing a single operation on multiple sets of the aligned data through parallel processing with a SIMD processor.
 18. The method of claim 1, wherein said loading includes generating a mask of nulls and ones.
 19. A packed data manipulation method performed by a computer system, comprising the steps of: decoding a single pipe shifter instruction; identifying two concatenated packed data, each of n bits length and having a plurality of data elements of independent length; identifying a shift value; executing the instruction by logically shifting each of the concatenated packed data by a number of bits less than n and controlled by the shift value, said shifting being in opposite directions for the two concatenated packed data; and combining the shifted concatenated packed data to obtain single aligned data of n bits.
 20. A method of manipulating two n bit strings of data, said method being performed by a computer system executing a stand alone implementation of a single instruction that does not require the support of other instructions, comprising the steps of: receiving first data from a first source register specified by a parameter of the instruction; receiving second data specified by a parameter of the instruction; receiving third data specified by a parameter of the instruction; shifting left the first data an amount specified by the third data to obtain a first intermediate data; generating mask data from the third data; executing an AND logical operation of the second data with the mask data to obtain second intermediate data; and executing an OR logical operation of the first intermediate data with the second intermediate data to obtain result data; and storing the result data. 